def superPow(a: int, b: list) -> int:
    MOD = 1337
    if not b:
        return 1
    if len(b) == 1:
        return pow(a, b[0], MOD)
    last = b[-1]
    rest = b[:-1]
    part1 = pow(superPow(a, rest), 10, MOD)
    part2 = pow(a, last, MOD)
    return (part1 * part2) % MOD